$(function() {
    let href = location.href;

    function getUrlParams(url) {
        let reg = /^[^\s]+\?([^&\s\d]+=[^\s]+)*/
        let match = reg.exec(url)
        match = match[1]
        if (!match) { 
            console.warn("没有匹配到相应的query参数")
            return null
        }
        let queryString = decodeURI(match);
        let queryArr = queryString.split("&");
        let queryParamsObj = {}
        queryArr.forEach(item => {
            let itemArr = item.split("=") 
            queryParamsObj[itemArr[0]] = itemArr[1]
        })
        return queryParamsObj
    }
    let qr = getUrlParams(href)
    let {
        productid
    } = qr; 


    $.ajax({
            url: "http://chst.vip:1234/api/getmoneyctrlproduct",
            data: {
                productid
            }
        })
        .then(res => {
            let {
                result: [info]
            } = res; 
            console.log(info);

            let html = `
        <li>
        <a href="" class="clear_float">
            <div class="infoR">
                <div class="title">
                    <h4>${info.productName}</h4>
                </div>
                <div class="other">
                    <span class="mall fl">${info.productFrom} &nbsp|&nbsp${info.productTime}</span>
                    <i>${info.productTips}</i>
                </div>
                <div class="container">
                <p>
                ${info.productImg2}
                ${info.productInfo2}
                </p>
                </div>
                 <div class="bigimg">
                ${info.productImg2}
                </div>
                <div class="city">
                ${info.productCity}
                </div>
            </div>
        </a>
    </li>
            `;
            let list = `
            ${info.productComment}
            `;
            $("ul").html(html);
            $(".comment").html(list);
        })

})